<template>
	<view class="content">
		<view class="input-block" style="margin-top:24rpx;">
			<input class="input-class" placeholder="请输入扣款余额" type="number" v-model="params.money" />
		</view>
		<view class="input-block" style="margin-top:24rpx;">
			<input class="input-class" placeholder="请输入扣款备注" type="text" v-model="params.remark" />
		</view>
		<view class="btn-block" @click="submitClick">
			确认扣款
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId:'',
				indexCurrent: 99,
				isResult: false, //查询结果
				transferMoney: '',
				keyWord: '',
				userInfo: {},
				userLst: [], //搜索出来的用户
				checkUser: {}, //选中的用户信息
				params: {
					money: '',
					remark: '',
					merchantId:"",
					userId:'',
					uuid:''
				}
			}
		},
		onLoad(e) {
			if(e){
				this.userId=e.userId
				this.params.userId=e.userId
				this.params.uuid=e.uuid
			}
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			getmoneyRecordInfo() {
				uni.showLoading({
					title: '加载中'
				})
				this.$http('common.getmoneyRecord', {
					token: this.$tools.getToken()
				}).then(res => {
					uni.hideLoading()
					if (res.code == 200) {
						console.log('res', res)
					}
				})
			},
			getUserInfo() {
				let that=this
				let adminId=uni.getStorageSync('adminId')
				let token=uni.getStorageSync('token')
				uni.request({
					url: 'https://api.shaoyanghmk.cn/admin/' + adminId, //仅为示例，并非真实接口地址。
					header: {
						'Token': token //自定义请求头信息
					},
					success: (res) => {
						let data = res.data
						console.log(data);
						if(data.status==0){
							that.params.merchantId=data.data.merchant.id
							console.log('that.params.merchantId==',that.params.merchantId)
						}
					}
				}); 		  
			},
			testClick(){
				 this.submitClick()
			},
			/**
			 * 
			 */
			submitClick() {
				if (!this.params.money) {
					return this.$tools.showMsg('扣款余额不能为空')
				}
				if (this.params.money < 0) {
					return this.$tools.showMsg('发放积分需要大于0')
				}
				if (!this.params.remark) {
					return this.$tools.showMsg('备注不能为空')
				}
				let that = this
				uni.showModal({
					title: '提示',
					content: `是否确认将${that.params.money}余额进行扣款?`,
					confirmText: '确认扣款',
					confirmColor: '#e43130',
					success(res) {
						if (res.confirm) {
							that.addFn()
						} else {

						}
					}
				})
			},
			lstLookClick() {
				uni.navigateTo({
					url: '/pages/user/wallet/transfer/tranferLst/tranferLst'
				})
			},
			addFn() {
				this.$http('common.updateDeleteUserMoneysNew', {
					...this.params
				}).then(res => {
					if (res.status == 0) {
						this.$tools.showMsg('扣款成功')
						this.params.money = ''
						this.params.remark = ''
						this.params.mobile = ''
						setTimeout(()=>{
							 uni.reLaunch({
							 	url:'/pages/index/index'
							 })
						},600)
					} else {
						this.$tools.showMsg(res.msg)
					}
				})
			},
			radioChange(e) {
				let userIndex = e.detail.value
				this.indexCurrent = userIndex
				console.log('userIndex', userIndex)
				this.checkUser = this.userLst[userIndex]
				this.isResult = true
			},
			keyWordBtnClick() {
				this.checkUser = {}
				this.userLst = []
				this.checkUser = false
				if (!this.keyWord) {
					return this.$tools.showMsg('请输入转账用户昵称或手机号')
				}
				uni.showLoading({
					title: '查询中'
				})
				this.$http("user.getKeywordList", {
					keyword: this.keyWord
				}).then(res => {
					this.isResult = true
					uni.hideLoading()
					console.log('res', res)
					if (res.code == 200) {
						this.userLst = res.data
					}
				})
			},
			//扫描二维码
			scanCodeClick(){
				let that = this
				uni.scanCode({
					success: function(res) {
						 console.log('res',res)
						 that.params.mobile=res.result
					},
					fail(err) {
						console.log('条码内容：err' + err.result);
						console.log('条码内容：err' + err.scanType);
					}
				});
			}
		}
	}
</script>
<style>
	page {
		background: #f5f5f5;
	}
</style>
<style lang="scss">
	.content {
		margin: 24rpx 16rpx;

	}

	.btn-keyword {
		padding: 16rpx;
		margin: 24rpx 0;
		border-radius: 8rpx;
		background: linear-gradient(159deg, #42A2DE 0%, #0089CF 63%);
		display: flex;
		align-items: center;
		justify-content: center;
		color: #FFFFFF;
		font-size: 28rpx;
		height: 62rpx;
		width: 160rpx;
	}

	.input-block {
		padding: 24rpx;
		background: #fff;
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		.code-img{
			width:48rpx;
			height: 48rpx;
			flex:none;
			margin-right: 14rpx;
		}
	}

	.item {
		background: #fff;
		border-radius: 8rpx;
		padding: 24rpx 18rpx;
		margin-bottom: 24rpx;

		.content-block {
			display: flex;
			align-items: center;
			margin-left: 16rpx;
			margin-right: 16rpx;

			.left-block {
				width: 124rpx;
				height: 124rpx;
				border-radius: 50%;
			}

			.right-info {
				margin-left: 24rpx;

				.txt {
					padding-top: 14rpx;
					font-size: 28rpx;
					color: #a1a1a3;
				}
			}
		}

		.report {
			margin-top: 18rpx;
			flex: auto;
			font-size: 28rpx;
			background: #fafafa;
			border-radius: 8rpx;
			padding: 12rpx 18rpx;
			display: flex;
			align-items: center;
		}

		.bottom-block {
			margin-top: 18rpx;
			display: flex;
			align-items: center;
			margin-left: 16rpx;
			margin-right: 16rpx;

			.hint-txt {
				flex: auto;
				font-size: 28rpx;
				background: #fafafa;
				border-radius: 8rpx;
				padding: 12rpx 18rpx;

				span {
					color: red;
				}
			}

			.btn-ok {
				margin-left: 24rpx;
				// background: #212e5b;
				flex: none;
				color: #fff;
				font-size: 28rpx;
				padding: 12rpx 18rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 8rpx;
			}
		}
	}

	.hint-block {
		// margin-left: 24rpx;
		// margin-right: 24rpx;

		.hint-txt {
			font-weight: bold;
			font-size: 30rpx;
			color: #020B00;
			padding: 24rpx;
			margin-bottom: 20rpx;
			background: linear-gradient(270deg, #EAFDFF 0%, #FFFFFF 100%);
		}
	}

	.btn-block {
		display: flex;
		align-items: center;
		justify-content: center;
		color: #FFFFFF;
		font-size: 28rpx;
		height: 90rpx;
		position: fixed;
		left: 24rpx;
		right: 24rpx;
		bottom: 44rpx;
		border-radius: 8rpx;
		background: linear-gradient(159deg, #42A2DE 0%, #0089CF 63%);
	}

	.block {

		.item-option {
			width: 100%;
			display: flex;
			background: #fff;
			align-items: center;
			padding: 24rpx;
			margin-bottom: 24rpx;

			.img {
				flex: none;
				width: 62rpx;
				height: 62rpx;
				border-radius: 50%;
			}

			.right-option {
				flex: auto;
				margin-left: 24rpx;

				.username {
					padding-bottom: 14rpx;

					span {
						color: #e43130;
					}
				}

				.mobile {}
			}

			.radio-option {
				flex: none;
				margin-right: 64rpx;
			}

		}
	}

	.hint-lst-block {
		font-weight: bold;
		font-size: 28rpx;
		color: #020B00;
		position: fixed;
		left: 24rpx;
		right: 24rpx;
		text-align: center;
		bottom: 164rpx;

	}
</style>